#include "core/error.hpp"

#include <csignal>
#include <exception>

MetaLog* logOut;

void error(const std::string& m)
{
  logOut << std::string(RED) << std::string("[error]: ") << std::string(RESET) << m << std::string("\n");
  if(isTesting)
    {
      throw 0;
    }
  else
    {
      raise(SIGTERM);
    }
}

void warning(const std::string& m)
{
  logOut << std::string(BLUE) << std::string("[warning]: ") << std::string(RESET) << m << std::string("\n");
}

void info(const std::string& m)
{
  logOut << m << std::string(RESET) << std::string("\n");
}

void init_error()
{
  logOut = new MetaLog;
}

void exit_error()
{
  delete logOut;
}
